package cn.wp.common.core.model;

import com.google.common.collect.Lists;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * 树形数据结构
 * Created by chenyb on 2019/12/24
 */
public class WpTree extends LinkedHashMap implements Serializable {

    // 树节点属性常量
    public static final String TREE_ID = "id";
    public static final String TREE_NAME = "name";
    public static final String TREE_CODE = "code";
    public static final String TREE_ICON = "icon";
    public static final String TREE_EXTRA = "extra";
    public static final String TREE_CHILD = "child";
    public static final String TREE_LEFA = "leaf";
    public static final String TREE_URL = "url";
    public static final String TREE_PARENT_ID = "pid";


    // 数据ID
    private String id;

    // 显示名称
    private String name;

    // 编码
    private String code;

    // 图标
    private String icon;

    // 扩展参数，可组装为json，前台进行解析
    private String extra;

    // 是否为叶子节点
    private boolean leaf;

    // 链接
    private String url;

    // 父节点ID
    private String pid;

    // 子节点
    private List<WpTree> child = Lists.newArrayList();

    public String getId() {
        this.id = String.valueOf(super.get(TREE_ID));
        return id;
    }

    public void setId(String id) {
        this.id = id;
        super.put(TREE_ID, id);
    }

    public String getName() {
        this.name = String.valueOf(super.get(TREE_NAME));
        return name;
    }

    public void setName(String name) {
        this.name = name;
        super.put(TREE_NAME, name);
    }

    public String getCode() {
        this.code = String.valueOf(super.get(TREE_CODE));
        return code;
    }

    public void setCode(String code) {
        this.code = code;
        super.put(TREE_CODE, code);
    }

    public String getIcon() {
        this.icon = String.valueOf(super.get(TREE_ICON));
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
        super.put(TREE_ICON, icon);
    }

    public List<WpTree> getChild() {
        this.child = (List<WpTree>)super.get(TREE_CHILD);
        return child;
    }

    public void setChild(List<WpTree> child) {
        this.child = child;
        super.put(TREE_CHILD,child);
    }

    public String getExtra() {
        this.extra = (String)super.get(TREE_EXTRA);
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
        super.put(TREE_EXTRA,extra);
    }

    public boolean isLeaf() {
        this.leaf = (Boolean)super.get(TREE_LEFA);
        return leaf;
    }

    public void setLeaf(boolean leaf) {
        leaf = leaf;
        super.put(TREE_LEFA,leaf);
    }

    public String getUrl() {
        this.url = (String)super.get(TREE_URL);
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
        super.put(TREE_URL,url);
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }
}
